﻿using System.Linq;

namespace CAION2.Classes
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;

    using Properties;

    public static class CardStat
    {
        public static KeyValuePair<string, float> GetStat(string stat)
        {
            stat = stat.Trim();
            string[] bonusValue = stat.Split(' ');
            if (bonusValue[0].Length == 0) return new KeyValuePair<string, Single>();

            if (bonusValue.Count() == 1)
            {
                Array.Resize(ref bonusValue, 2); 
                bonusValue[1] = "0";
            }
            else
            {
                if (bonusValue[1].Length > 0 && bonusValue[0].Contains("PvP"))
                {
                    bonusValue[1] = (Convert.ToDouble(bonusValue[1]) / 10).ToString(CultureInfo.InvariantCulture);
                }

                if (bonusValue[1].Length == 0 && bonusValue[2].Length > 0)
                {
                    bonusValue[1] = bonusValue[2];
                }
            }

            //if (bonusValue[0] == "boosthate")
            //{
            //    Single corValue = Convert.ToSingle(bonusValue[1].Substring(1, bonusValue[1].Length - 2));
            //    corValue = corValue / 10;
            //    bonusValue[1] = corValue.ToString(CultureInfo.InvariantCulture);
            //}

            bonusValue[1] = bonusValue[1].Replace("%", "");

            return new KeyValuePair<string, Single>(bonusValue[0].ToLower(), Convert.ToSingle(bonusValue[1]));
        }

        public static string GetStatTranslate(String stat)
        {
            switch (stat.ToLower())
            {
                case "physicaldefend": return Resources._StatsPhysicalDefend;
                case "phyattack": return Resources._StatsPhyAttack;
                case "phyattack_l": return Resources._StatsPhyAttack_l;
                case "parry": return Resources._StatsParry;
                case "maxmp": return Resources._StatsMaxMP;
                case "maxhp": return Resources._StatsMaxHP;
                case "maxfp": return Resources._StatsMaxFP;
                case "magicalskillboost": return Resources._StatsMagicalSkillBoost;
                case "magicalresist": return Resources._StatsMagicalResist;
                case "magicalhitaccuracy": return Resources._StatsMagicalHitAccuracy;
                case "magicalattack": return Resources._StatsMagicAttack;
                case "hitaccuracy": return Resources._StatsHitAccuracy;
                case "hitaccuracy_l": return Resources._StatsHitAccuracy_l;
                case "flyspeed": return Resources._StatsFlySpeed;
                case "elementaldefendfire": return Resources._StatsElementalDefendFire;
                case "elementaldefendair": return Resources._StatsElementalDefendAir;
                case "dodge": return Resources._StatsDodge;
                case "critical": return Resources._StatsCritical;
                case "critical_l": return Resources._StatsCritical_l;
                case "block": return Resources._StatsBlock;
                case "magicalblock": return Resources._StatsMagicalBlock;
                case "attackdelay": return Resources._StatsAttackDelay;
                case "speed": return Resources._StatsSpeed;
                case "magicalcritical": return Resources._StatsMagicalCritical;
                case "elementaldefendwater": return Resources._StatsElementalDefendWater;
                case "elementaldefendearth": return Resources._StatsElementalDefendEarth;
                case "concentration": return Resources._StatsConcentration;
                case "boostcastingtime": return Resources._StatsBoostCastingTime;
                case "boosthate": return Resources._StatsBoostHate;
                case "physicalcriticaldamagereduce": return Resources._StatsPhysicalCriticalDamageReduce;
                case "pvpdefendratio": return Resources._StatsPvpDefendRatio;
                case "healskillboost": return Resources._StatsHealSkillBoost;
                case "physicalcriticalreducerate": return Resources._StatsPhysicalCriticalReduceRate;
                case "pvpattackratio": return Resources._StatsPvpAttackRatio;
                case "magicalcriticalreducerate": return Resources._StatsMagicalCriticalReduceRate;
                case "magicalcriticaldamagereduce": return Resources._StatsMagicalCriticalDamageReduce;
                case "arparalyze": return Resources._StatsParalize;
                case "arsilence": return Resources._StatsSilence;
                case "magicalskillboostresist": return Resources._StatsMagicalSkillBoostResist;
                case "silence_arp": return Resources._StatsSilenceArp;
                case "paralyze_arp": return Resources._StatsParalizeArp;
                case "pvpattackratio_physical": return Resources._StatsPvpAttackRatioPhysical;
                case "damagereduce": return Resources._StatsDamageReduce;
                case "arstumble": return Resources._StatsStumble;
                case "stumble_arp": return Resources._StatsStumbleArp;
                case "arstagger": return Resources._StatsStagger;
                case "stagger_arp": return Resources._StatsStaggerArp;
            }

            return stat;
        }
    }
}
